package com.jicheng.config.web;

import com.jicheng.interceptor.LogInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: ConfigurerAdapter
 * @Description: TODO
 * @author: khz
 * @date: 2020年10月13日 18:12
 */
@Configuration
public class ConfigurerAdapter implements WebMvcConfigurer {

    //设置排除路径，spring boot 2.*，注意排除掉静态资源的路径，不然静态资源无法访问
    private final String[] excludePath = {"/doc.html","/swagger-resources","/webjars/**","/getToken","/getVerifyCode","/login","/logout","/file/**","/app-file/**"};

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 添加日志的拦截器
         */
        registry.addInterceptor(new LogInterceptor()).addPathPatterns("/**").excludePathPatterns(excludePath);
    }
}